package reflect;

import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo7 {
    public static void main(String[] args) throws Exception{
        //传统方法：
        Person p = new Person();
        p.say("你好");

        Class cls = Class.forName("reflect.Person");
        Object o = cls.newInstance();
        Method method = cls.getMethod("say",String.class);
        method.invoke(o,"你好啊");

        Method method1 = cls.getMethod("say", String.class, int.class);
        method1.invoke(o,"法外狂徒！",5);
    }
}
